<?php
	class Admincp_Model_Page extends Zend_Db_Table_Abstract
	{
		protected $_name = 'page';
		protected $_primary = 'id';
		protected $_db;
		
		public function __construct()
		{
			$this->_db = Zend_Registry::get('db');
		}
        
        public function listItem()
        {
            $data = array(
                'id',
                'title',
            );
            $sql = $this->_db->select()
                            ->from($this->_name, $data)
                            ->order('id DESC');
            $result = $this->_db->fetchAll($sql);
            return $result;
        }
        
        public function getItem($id)
        {
            $sql = $this->_db->select()
                            ->from($this->_name, array('id', 'title', 'description'))
                            ->where('id = ?', $id);
            $result = $this->_db->fetchRow($sql);
            return $result;
        }
        
        public function saveItem($data, $id)
        {
            $where = $this->getAdapter()->quoteInto('id = ?', $id);
            $this->_db->update($this->_name, $data, $where);
        }
    }
